package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.ImmMember;
import com.drug.mingkang.Mapper.ImmMemberMapper;
import com.drug.mingkang.service.ImmMemberService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ImmMember)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:44
 */
@Service("immMemberService")
public class ImmMemberServiceImpl implements ImmMemberService {
    @Resource
    private ImmMemberMapper immMemberMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param memberId 主键
     * @return 实例对象
     */
    @Override
    public ImmMember queryById(String memberId) {
        return this.immMemberMapper.queryById(memberId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ImmMember> queryAllByLimit(int offset, int limit) {
        return this.immMemberMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param immMember 实例对象
     * @return 实例对象
     */
    @Override
    public ImmMember insert(ImmMember immMember) {
        this.immMemberMapper.insert(immMember);
        return immMember;
    }

    /**
     * 修改数据
     *
     * @param immMember 实例对象
     * @return 实例对象
     */
    @Override
    public ImmMember update(ImmMember immMember) {
        this.immMemberMapper.update(immMember);
        return this.queryById(immMember.getMemberId());
    }

    /**
     * 通过主键删除数据
     *
     * @param memberId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String memberId) {
        return this.immMemberMapper.deleteById(memberId) > 0;
    }
}